using DevExpress.XtraTab;
using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace NoteManger
{
	public class FrmViewWjwsh : Form
	{
		private string[,] aNoteItems = new string[0, 0];
		private NoteRemote _NoteRemoteObject = null;
		private TLoginInfo _LoginInfo = new TLoginInfo();
		private IContainer components = null;
		private XtraTabControl xtraTabPageWsh;
		private XtraTabPage xtraTabPageWj;
		private XtraTabPage xtraTabPage2;
		private Button btnclose;
		private ListView listViewWjrz;
		private ListView listViewWshrz;
		private ImageList imageList;
		public NoteRemote NoteRemoteObject
		{
			set
			{
				this._NoteRemoteObject = value;
			}
		}
		public TLoginInfo LoginInfo
		{
			set
			{
				this._LoginInfo = value;
			}
		}
		public FrmViewWjwsh()
		{
			this.InitializeComponent();
			this.CreateColumn2(this.listViewWjrz, 0);
			this.CreateColumn2(this.listViewWshrz, 1);
		}
		private void CreateColumn2(ListView listViewNote, int iCreateFlag)
		{
			listViewNote.Items.Clear();
			listViewNote.Columns.Clear();
			ColumnHeader columnHeader = new ColumnHeader();
			columnHeader.Text = "日志日期";
			columnHeader.Width = 120;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "星期";
			columnHeader.Width = 100;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "用户代码";
			columnHeader.Width = 100;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "姓名";
			columnHeader.Width = 120;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "组名称";
			columnHeader.Width = 120;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "人员分类";
			columnHeader.Width = 120;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "角色名称";
			columnHeader.Width = 120;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			columnHeader = new ColumnHeader();
			columnHeader.Text = "日志审核人";
			columnHeader.Width = 120;
			columnHeader.TextAlign = HorizontalAlignment.Center;
			listViewNote.Columns.Add(columnHeader);
			if (iCreateFlag == 2)
			{
				columnHeader = new ColumnHeader();
				columnHeader.Text = "汇总工作量";
				columnHeader.Width = 150;
				columnHeader.TextAlign = HorizontalAlignment.Center;
				listViewNote.Columns.Add(columnHeader);
			}
			else
			{
				columnHeader = new ColumnHeader();
				columnHeader.Text = "状态";
				columnHeader.Width = 150;
				columnHeader.TextAlign = HorizontalAlignment.Center;
				listViewNote.Columns.Add(columnHeader);
			}
		}
		private void btnclose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void GetNoteInfos(ListView listViewNote, string sBeginDate, string aEndDate, int iGetFlag)
		{
			if (this._NoteRemoteObject != null)
			{
				try
				{
					if (!this._NoteRemoteObject.ConnectionTest())
					{
						MessageBox.Show("远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
						return;
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message + "远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					return;
				}
				string text = "";
				bool flag = false;
				try
				{
					if (iGetFlag == 0)
					{
						string text2 = "0";
						flag = this._NoteRemoteObject.CommonQuery(string.Concat(new string[]
						{
							"exec usp_wn_querywjwshnote '",
							sBeginDate,
							"','",
							aEndDate,
							"',",
							text2,
							",",
							iGetFlag.ToString(),
							",'",
							this._LoginInfo.LoginID,
							"'"
						}), ref this.aNoteItems, ref text);
					}
					else
					{
						flag = this._NoteRemoteObject.CommonQuery(string.Concat(new string[]
						{
							"exec usp_wn_querywjwshnote '",
							sBeginDate,
							"','",
							aEndDate,
							"',0,",
							iGetFlag.ToString(),
							",'",
							this._LoginInfo.LoginID,
							"'"
						}), ref this.aNoteItems, ref text);
					}
				}
				catch (Exception ex)
				{
					MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				if (flag)
				{
					int num = this.aNoteItems.GetUpperBound(0) - this.aNoteItems.GetLowerBound(0) + 1;
					listViewNote.BeginUpdate();
					listViewNote.Items.Clear();
					listViewNote.Groups.Clear();
					for (int i = 0; i < num; i++)
					{
						ListViewItem listViewItem = new ListViewItem();
						listViewItem.Text = this.aNoteItems[i, 0];
						listViewItem.SubItems.Add(this.aNoteItems[i, 1]);
						listViewItem.SubItems.Add(this.aNoteItems[i, 2]);
						listViewItem.SubItems.Add(this.aNoteItems[i, 3]);
						listViewItem.SubItems.Add(this.aNoteItems[i, 4]);
						listViewItem.SubItems.Add(this.aNoteItems[i, 5]);
						listViewItem.SubItems.Add(this.aNoteItems[i, 6]);
						listViewItem.SubItems.Add(this.aNoteItems[i, 7]);
						listViewItem.SubItems.Add(this.aNoteItems[i, 8]);
						listViewItem.ImageIndex = 1;
						listViewNote.Items.Add(listViewItem);
					}
					listViewNote.EndUpdate();
					listViewNote.Refresh();
				}
				else
				{
					MessageBox.Show(text, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
			}
		}
		private double GetAlarm0()
		{
			RegistryKey localMachine = Registry.LocalMachine;
			RegistryKey registryKey = localMachine.OpenSubKey("Software\\KSExpert", true);
			object value = registryKey.GetValue("Alarm0");
			double result;
			if (value == null)
			{
				registryKey.Close();
				localMachine.Close();
				result = 0.0;
			}
			else
			{
				registryKey.Close();
				localMachine.Close();
				result = Convert.ToDouble(value);
			}
			return result;
		}
		private double GetAlarm1()
		{
			RegistryKey localMachine = Registry.LocalMachine;
			RegistryKey registryKey = localMachine.OpenSubKey("Software\\KSExpert", true);
			object value = registryKey.GetValue("Alarm1");
			double result;
			if (value == null)
			{
				registryKey.Close();
				localMachine.Close();
				result = 0.0;
			}
			else
			{
				registryKey.Close();
				localMachine.Close();
				result = Convert.ToDouble(value);
			}
			return result;
		}
		private void FrmViewWjwsh_Load(object sender, EventArgs e)
		{
			this.GetNoteInfos(this.listViewWjrz, "2009-02-09", DateTime.Now.AddDays(-this.GetAlarm0()).ToString("yyyy-MM-dd"), 0);
			this.GetNoteInfos(this.listViewWshrz, "2009-02-09", DateTime.Now.AddDays(-this.GetAlarm1()).ToString("yyyy-MM-dd"), 1);
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(FrmViewWjwsh));
			this.xtraTabPageWsh = new XtraTabControl();
			this.xtraTabPageWj = new XtraTabPage();
			this.listViewWjrz = new ListView();
			this.imageList = new ImageList(this.components);
			this.xtraTabPage2 = new XtraTabPage();
			this.listViewWshrz = new ListView();
			this.btnclose = new Button();
			((ISupportInitialize)this.xtraTabPageWsh).BeginInit();
			this.xtraTabPageWsh.SuspendLayout();
			this.xtraTabPageWj.SuspendLayout();
			this.xtraTabPage2.SuspendLayout();
			base.SuspendLayout();
			this.xtraTabPageWsh.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.xtraTabPageWsh.Location = new System.Drawing.Point(7, 7);
			this.xtraTabPageWsh.Name = "xtraTabPageWsh";
			this.xtraTabPageWsh.SelectedTabPage = this.xtraTabPageWj;
			this.xtraTabPageWsh.Size = new System.Drawing.Size(595, 344);
			this.xtraTabPageWsh.TabIndex = 0;
			this.xtraTabPageWsh.TabPages.AddRange(new XtraTabPage[]
			{
				this.xtraTabPageWj,
				this.xtraTabPage2
			});
			this.xtraTabPageWj.Controls.Add(this.listViewWjrz);
			this.xtraTabPageWj.Name = "xtraTabPageWj";
			this.xtraTabPageWj.Size = new System.Drawing.Size(586, 312);
			this.xtraTabPageWj.Text = "我的未交日志";
			this.listViewWjrz.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.listViewWjrz.FullRowSelect = true;
			this.listViewWjrz.GridLines = true;
			this.listViewWjrz.HideSelection = false;
			this.listViewWjrz.Location = new System.Drawing.Point(2, 3);
			this.listViewWjrz.MultiSelect = false;
			this.listViewWjrz.Name = "listViewWjrz";
			this.listViewWjrz.ShowItemToolTips = true;
			this.listViewWjrz.Size = new System.Drawing.Size(583, 308);
			this.listViewWjrz.SmallImageList = this.imageList;
			this.listViewWjrz.TabIndex = 25;
			this.listViewWjrz.UseCompatibleStateImageBehavior = false;
			this.listViewWjrz.View = View.Details;
			this.imageList.ImageStream = (ImageListStreamer)componentResourceManager.GetObject("imageList.ImageStream");
			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
			this.imageList.Images.SetKeyName(0, "summary.ico");
			this.imageList.Images.SetKeyName(1, "Card.ico");
			this.imageList.Images.SetKeyName(2, "Card-Add.ico");
			this.imageList.Images.SetKeyName(3, "Card-Delete.ico");
			this.imageList.Images.SetKeyName(4, "Mail-Forward.ico");
			this.imageList.Images.SetKeyName(5, "Connect.ico");
			this.imageList.Images.SetKeyName(6, "Certificate.ico");
			this.imageList.Images.SetKeyName(7, "Loginout.ico");
			this.imageList.Images.SetKeyName(8, "key.ico");
			this.imageList.Images.SetKeyName(9, "User-Add.ico");
			this.imageList.Images.SetKeyName(10, "configure.ico");
			this.imageList.Images.SetKeyName(11, "refresh.ico");
			this.imageList.Images.SetKeyName(12, "Card-New.ico");
			this.imageList.Images.SetKeyName(13, "Card-Edit.ico");
			this.imageList.Images.SetKeyName(14, "convert.ico");
			this.imageList.Images.SetKeyName(15, "search.ico");
			this.imageList.Images.SetKeyName(16, "Export.ico");
			this.imageList.Images.SetKeyName(17, "Flow Chart.ico");
			this.imageList.Images.SetKeyName(18, "User-Edit.ico");
			this.imageList.Images.SetKeyName(19, "User-Security-2.ico");
			this.xtraTabPage2.Controls.Add(this.listViewWshrz);
			this.xtraTabPage2.Name = "xtraTabPage2";
			this.xtraTabPage2.Size = new System.Drawing.Size(586, 312);
			this.xtraTabPage2.Text = "我的未审核日志";
			this.listViewWshrz.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.listViewWshrz.FullRowSelect = true;
			this.listViewWshrz.GridLines = true;
			this.listViewWshrz.HideSelection = false;
			this.listViewWshrz.Location = new System.Drawing.Point(2, 3);
			this.listViewWshrz.MultiSelect = false;
			this.listViewWshrz.Name = "listViewWshrz";
			this.listViewWshrz.ShowItemToolTips = true;
			this.listViewWshrz.Size = new System.Drawing.Size(583, 308);
			this.listViewWshrz.SmallImageList = this.imageList;
			this.listViewWshrz.TabIndex = 26;
			this.listViewWshrz.UseCompatibleStateImageBehavior = false;
			this.listViewWshrz.View = View.Details;
			this.btnclose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnclose.Location = new System.Drawing.Point(515, 355);
			this.btnclose.Name = "btnclose";
			this.btnclose.Size = new System.Drawing.Size(83, 25);
			this.btnclose.TabIndex = 1;
			this.btnclose.Text = "关闭(&C)";
			this.btnclose.UseVisualStyleBackColor = true;
			this.btnclose.Click += new EventHandler(this.btnclose_Click);
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new System.Drawing.Size(607, 387);
			base.Controls.Add(this.btnclose);
			base.Controls.Add(this.xtraTabPageWsh);
			base.Name = "FrmViewWjwsh";
			base.ShowInTaskbar = false;
			this.Text = "未交、未审核日志查询";
			base.WindowState = FormWindowState.Maximized;
			base.Load += new EventHandler(this.FrmViewWjwsh_Load);
			((ISupportInitialize)this.xtraTabPageWsh).EndInit();
			this.xtraTabPageWsh.ResumeLayout(false);
			this.xtraTabPageWj.ResumeLayout(false);
			this.xtraTabPage2.ResumeLayout(false);
			base.ResumeLayout(false);
		}
	}
}
